use e_utils::parse::AutoPath;
use rayon::prelude::*;
use std::{collections::HashMap, fs::copy, path::Path};
fn main() {
  let mut x = HashMap::new();
  x.insert(
    "sn_3pcs",
    vec![
      "CB72I18SI-2HG231119250XAG0181",
      "CB72I18SI-2HG231119250XAG0162",
      "CB72I18SI-2HG231119250XAG0435",
    ],
  );
  x.insert(
    "sn_25pcs",
    vec![
      "CB72I18SI-2HG231105390XAG0013",
      "CB72I18SI-2HG231105390XAG0007",
      "CB72I18SI-2HG231105390XAG0059",
      "CB72I18SI-2HG231105390XAG0017",
      "CB72I18SI-2HG231105390XAG0074",
      "CB72I18SI-2HG231105390XAG0045",
      "CB72I18SI-2HG231105390XAG0001",
      "CB72I18SI-2HG231105390XAG0099",
      "CB72I18SI-2HG231105390XAG0015",
      "CB72I18SI-2HG231105390XAG0078",
      "CB72I18SI-2HG231105390XAG0052",
      "CB72I18SI-2HG231105390XAG0087",
      "CB72I18SI-2HG231105390XAG0086",
      "CB72I18SI-2HG231105390XAG0056",
      "CB72I18SI-2HG231105390XAG0071",
      "CB72I18SI-2HG231105390XAG0094",
      "CB72I18SI-2HG231105390XAG0096",
      "CB72I18SI-2HG231105390XAG0081",
      "CB72I18SI-2HG231105390XAG0006",
      "CB72I18SI-2HG231105390XAG0075",
      "CB72I18SI-2HG231105390XAG0047",
      "CB72I18SI-2HG231105390XAG0037",
      "CB72I18SI-2HG231105390XAG0079",
      "CB72I18SI-2HG231105390XAG0076",
      "CB72I18SI-2HG231105390XAG0089",
    ],
  );
  x.insert(
    "sn_30pcs",
    vec![
      "CB72I18SI-2HG231105390XAG0011",
      "CB72I18SI-2HG231105390XAG0024",
      "CB72I18SI-2HG231105390XAG0034",
      "CB72I18SI-2HG231105390XAG0084",
      "CB72I18SI-2HG231105390XAG0021",
      "CB72I18SI-2HG231105390XAG0097",
      "CB72I18SI-2HG231105390XAG0095",
      "CB72I18SI-2HG231105390XAG0068",
      "CB72I18SI-2HG231105390XAG0083",
      "CB72I18SI-2HG231105390XAG0088",
      "CB72I18SI-2HG231105390XAG0085",
      "CB72I18SI-2HG231105390XAG0002",
      "CB72I18SI-2HG231105390XAG0003",
      "CB72I18SI-2HG231105390XAG0019",
      "CB72I18SI-2HG231105390XAG0100",
      "CB72I18SI-2HG231105390XAG0040",
      "CB72I18SI-2HG231105390XAG0069",
      "CB72I18SI-2HG231105390XAG0066",
      "CB72I18SI-2HG231105390XAG0103",
      "CB72I18SI-2HG231105390XAG0020",
      "CB72I18SI-2HG231105390XAG0042",
      "CB72I18SI-2HG231105390XAG0092",
      "CB72I18SI-2HG231105390XAG0039",
      "CB72I18SI-2HG231105390XAG0060",
      "CB72I18SI-2HG231105390XAG0025",
      "CB72I18SI-2HG231105390XAG0031",
      "CB72I18SI-2HG231105390XAG0008",
      "CB72I18SI-2HG231105390XAG0029",
      "CB72I18SI-2HG231105390XAG0058",
      "CB72I18SI-2HG231105390XAG0010",
    ],
  );
  x.insert(
    "sn_38pcs",
    vec![
      "CB72I18SI-2HG230912920XAG0039",
      "CB72I18SI-2HG230912920XAG0192",
      "CB72I18SI-2HG230912920XAG0070",
      "CB72I18SI-2HG230912920XAG0262",
      "CB72I18SI-2HG230912920XAG0205",
      "CB72I18SI-2HG230912920XAG0026",
      "CB72I18SI-2HG230912920XAG0085",
      "CB72I18SI-2HG230912920XAG0063",
      "CB72I18SI-2HG230912920XAG0114",
      "CB72I18SI-2HG230912920XAG0221",
      "CB72I18SI-2HG230912920XAG0089",
      "CB72I18SI-2HG230912920XAG0021",
      "CB72I18SI-2HG230912920XAG0023",
      "CB72I18SI-2HG230912920XAG0111",
      "CB72I18SI-2HG230912920XAG0130",
      "CB72I18SI-2HG230912920XAG0069",
      "CB72I18SI-2HG230912920XAG0035",
      "CB72I18SI-2HG230912920XAG0052",
      "CB72I18SI-2HG230912920XAG0012",
      "CB72I18SI-2HG230912920XAG0135",
      "CB72I18SI-2HG230912920XAG0234",
      "CB72I18SI-2HG230912920XAG0084",
      "CB72I18SI-2HG230912920XAG0142",
      "CB72I18SI-2HG230912920XAG0261",
      "CB72I18SI-2HG230912920XAG0178",
      "CB72I18SI-2HG230912920XAG0158",
      "CB72I18SI-2HG230912920XAG0164",
      "CB72I18SI-2HG230912920XAG0150",
      "CB72I18SI-2HG230912920XAG0045",
      "CB72I18SI-2HG230912920XAG0247",
      "CB72I18SI-2HG230912920XAG0162",
      "CB72I18SI-2HG230912920XAG0159",
      "CB72I18SI-2HG230912920XAG0236",
      "CB72I18SI-2HG230912920XAG0014",
      "CB72I18SI-2HG230912920XAG0031",
      "CB72I18SI-2HG230912920XAG0118",
      "CB72I18SI-2HG230912920XAG0219",
    ],
  );
  x.insert(
    "sn_81pcs",
    vec![
      "CB72I18SI-2HG230912880XAG0330",
      "CB72I18SI-2HG230912880XAG0175",
      "CB72I18SI-2HG230912880XAG0177",
      "CB72I18SI-2HG230912880XAG0284",
      "CB72I18SI-2HG230912880XAG0339",
      "CB72I18SI-2HG230912880XAG0169",
      "CB72I18SI-2HG230912880XAG0219",
      "CB72I18SI-2HG230912880XAG0334",
      "CB72I18SI-2HG230912880XAG0200",
      "CB72I18SI-2HG230912880XAG0214",
      "CB72I18SI-2HG230912880XAG0323",
      "CB72I18SI-2HG230912880XAG0201",
      "CB72I18SI-2HG230912880XAG0311",
      "CB72I18SI-2HG230912880XAG0216",
      "CB72I18SI-2HG230912880XAG0312",
      "CB72I18SI-2HG230912880XAG0331",
      "CB72I18SI-2HG230912880XAG0304",
      "CB72I18SI-2HG230912880XAG0319",
      "CB72I18SI-2HG230912880XAG0343",
      "CB72I18SI-2HG230912880XAG0286",
      "CB72I18SI-2HG230912880XAG0293",
      "CB72I18SI-2HG230912880XAG0333",
      "CB72I18SI-2HG230912880XAG0077",
      "CB72I18SI-2HG230912880XAG0335",
      "CB72I18SI-2HG230912880XAG0309",
      "CB72I18SI-2HG230912880XAG0072",
      "CB72I18SI-2HG230912880XAG0132",
      "CB72I18SI-2HG230912880XAG0338",
      "CB72I18SI-2HG230912880XAG0064",
      "CB72I18SI-2HG230912880XAG0096",
      "CB72I18SI-2HG230912880XAG0131",
      "CB72I18SI-2HG230912880XAG0544",
      "CB72I18SI-2HG230912880XAG0233",
      "CB72I18SI-2HG230912880XAG0563",
      "CB72I18SI-2HG230912880XAG0570",
      "CB72I18SI-2HG230912880XAG0238",
      "CB72I18SI-2HG230912880XAG0420",
      "CB72I18SI-2HG230912880XAG0542",
      "CB72I18SI-2HG230912880XAG0722",
      "CB72I18SI-2HG230912880XAG0281",
      "CB72I18SI-2HG230912880XAG0118",
      "CB72I18SI-2HG230912880XAG0344",
      "CB72I18SI-2HG230912880XAG0734",
      "CB72I18SI-2HG230912880XAG0262",
      "CB72I18SI-2HG230912880XAG0287",
      "CB72I18SI-2HG230912880XAG0439",
      "CB72I18SI-2HG230912880XAG0513",
      "CB72I18SI-2HG230912880XAG0253",
      "CB72I18SI-2HG230912880XAG0355",
      "CB72I18SI-2HG230912880XAG0157",
      "CB72I18SI-2HG230912880XAG0263",
      "CB72I18SI-2HG230912880XAG0547",
      "CB72I18SI-2HG230912880XAG0526",
      "CB72I18SI-2HG230912880XAG0270",
      "CB72I18SI-2HG230912880XAG0282",
      "CB72I18SI-2HG230912880XAG0043",
      "CB72I18SI-2HG230912880XAG0235",
      "CB72I18SI-2HG230912880XAG0399",
      "CB72I18SI-2HG230912880XAG0045",
      "CB72I18SI-2HG230912880XAG0361",
      "CB72I18SI-2HG230912880XAG0532",
      "CB72I18SI-2HG230912880XAG0090",
      "CB72I18SI-2HG230912880XAG0533",
      "CB72I18SI-2HG230912880XAG0359",
      "CB72I18SI-2HG230912880XAG0241",
      "CB72I18SI-2HG230912880XAG0078",
      "CB72I18SI-2HG230912880XAG0372",
      "CB72I18SI-2HG230912880XAG0407",
      "CB72I18SI-2HG230912880XAG0374",
      "CB72I18SI-2HG230912880XAG0672",
      "CB72I18SI-2HG230912880XAG0576",
      "CB72I18SI-2HG230912880XAG0070",
      "CB72I18SI-2HG230912880XAG0370",
      "CB72I18SI-2HG230912880XAG0234",
      "CB72I18SI-2HG230912880XAG0494",
      "CB72I18SI-2HG230912880XAG0168",
      "CB72I18SI-2HG230912880XAG0364",
      "CB72I18SI-2HG230912880XAG0342",
      "CB72I18SI-2HG230912880XAG0743",
      "CB72I18SI-2HG230912880XAG0795",
      "CB72I18SI-2HG230912880XAG0814",
    ],
  );
  x.insert(
    "sn_140pcs",
    vec![
      "CB72I18SI-2HG231119280XAG0307",
      "CB72I18SI-2HG231119280XAG0316",
      "CB72I18SI-2HG231119280XAG0094",
      "CB72I18SI-2HG231119280XAG0025",
      "CB72I18SI-2HG231119280XAG0349",
      "CB72I18SI-2HG231119280XAG0013",
      "CB72I18SI-2HG231119280XAG0324",
      "CB72I18SI-2HG231119280XAG0151",
      "CB72I18SI-2HG231119280XAG0127",
      "CB72I18SI-2HG231119280XAG0143",
      "CB72I18SI-2HG231119280XAG0083",
      "CB72I18SI-2HG231119280XAG0043",
      "CB72I18SI-2HG231119280XAG0173",
      "CB72I18SI-2HG231119280XAG0019",
      "CB72I18SI-2HG231119280XAG0037",
      "CB72I18SI-2HG231119280XAG0165",
      "CB72I18SI-2HG231119280XAG0016",
      "CB72I18SI-2HG231119280XAG0339",
      "CB72I18SI-2HG231119280XAG0089",
      "CB72I18SI-2HG231119280XAG0155",
      "CB72I18SI-2HG231119280XAG0166",
      "CB72I18SI-2HG231119280XAG0067",
      "CB72I18SI-2HG231119280XAG0345",
      "CB72I18SI-2HG231119280XAG0170",
      "CB72I18SI-2HG231119280XAG0178",
      "CB72I18SI-2HG231119280XAG0186",
      "CB72I18SI-2HG231119280XAG0329",
      "CB72I18SI-2HG231119280XAG0070",
      "CB72I18SI-2HG231119280XAG0346",
      "CB72I18SI-2HG231119280XAG0004",
      "CB72I18SI-2HG231119280XAG0193",
      "CB72I18SI-2HG231119280XAG0109",
      "CB72I18SI-2HG231119280XAG0099",
      "CB72I18SI-2HG231119280XAG0080",
      "CB72I18SI-2HG231119280XAG0142",
      "CB72I18SI-2HG231119280XAG0125",
      "CB72I18SI-2HG231119280XAG0347",
      "CB72I18SI-2HG231119280XAG0135",
      "CB72I18SI-2HG231119280XAG0010",
      "CB72I18SI-2HG231119280XAG0014",
      "CB72I18SI-2HG231119280XAG0046",
      "CB72I18SI-2HG231119280XAG0091",
      "CB72I18SI-2HG231119280XAG0144",
      "CB72I18SI-2HG231119280XAG0057",
      "CB72I18SI-2HG231119280XAG0072",
      "CB72I18SI-2HG231119280XAG0130",
      "CB72I18SI-2HG231119280XAG0073",
      "CB72I18SI-2HG231119280XAG0208",
      "CB72I18SI-2HG231119280XAG0169",
      "CB72I18SI-2HG231119280XAG0167",
      "CB72I18SI-2HG231119280XAG0077",
      "CB72I18SI-2HG231119280XAG0150",
      "CB72I18SI-2HG231119280XAG0078",
      "CB72I18SI-2HG231119280XAG0228",
      "CB72I18SI-2HG231119280XAG0138",
      "CB72I18SI-2HG231119280XAG0197",
      "CB72I18SI-2HG231119280XAG0007",
      "CB72I18SI-2HG231119280XAG0312",
      "CB72I18SI-2HG231119280XAG0326",
      "CB72I18SI-2HG231119280XAG0097",
      "CB72I18SI-2HG231119280XAG0314",
      "CB72I18SI-2HG231119280XAG0095",
      "CB72I18SI-2HG231119280XAG0336",
      "CB72I18SI-2HG231119280XAG0323",
      "CB72I18SI-2HG231119280XAG0124",
      "CB72I18SI-2HG231119280XAG0333",
      "CB72I18SI-2HG231119280XAG0297",
      "CB72I18SI-2HG231119280XAG0096",
      "CB72I18SI-2HG231119280XAG0108",
      "CB72I18SI-2HG231119280XAG0100",
      "CB72I18SI-2HG231119280XAG0111",
      "CB72I18SI-2HG231119280XAG0140",
      "CB72I18SI-2HG231119280XAG0028",
      "CB72I18SI-2HG231119280XAG0087",
      "CB72I18SI-2HG231119280XAG0137",
      "CB72I18SI-2HG231119280XAG0177",
      "CB72I18SI-2HG231119280XAG0331",
      "CB72I18SI-2HG231119280XAG0341",
      "CB72I18SI-2HG231119280XAG0020",
      "CB72I18SI-2HG231119280XAG0063",
      "CB72I18SI-2HG231119280XAG0033",
      "CB72I18SI-2HG231119280XAG0126",
      "CB72I18SI-2HG231119280XAG0148",
      "CB72I18SI-2HG231119280XAG0015",
      "CB72I18SI-2HG231119280XAG0079",
      "CB72I18SI-2HG231119280XAG0168",
      "CB72I18SI-2HG231119280XAG0021",
      "CB72I18SI-2HG231119280XAG0294",
      "CB72I18SI-2HG231119280XAG0008",
      "CB72I18SI-2HG231119280XAG0012",
      "CB72I18SI-2HG231119280XAG0134",
      "CB72I18SI-2HG231119280XAG0024",
      "CB72I18SI-2HG231119280XAG0101",
      "CB72I18SI-2HG231119280XAG0090",
      "CB72I18SI-2HG231119280XAG0206",
      "CB72I18SI-2HG231119280XAG0194",
      "CB72I18SI-2HG231119280XAG0041",
      "CB72I18SI-2HG231119280XAG0179",
      "CB72I18SI-2HG231119280XAG0017",
      "CB72I18SI-2HG231119280XAG0048",
      "CB72I18SI-2HG231119280XAG0160",
      "CB72I18SI-2HG231119280XAG0313",
      "CB72I18SI-2HG231119280XAG0009",
      "CB72I18SI-2HG231119280XAG0234",
      "CB72I18SI-2HG231119280XAG0319",
      "CB72I18SI-2HG231119280XAG0081",
      "CB72I18SI-2HG231119280XAG0268",
      "CB72I18SI-2HG231119280XAG0153",
      "CB72I18SI-2HG231119280XAG0335",
      "CB72I18SI-2HG231119280XAG0245",
      "CB72I18SI-2HG231119280XAG0104",
      "CB72I18SI-2HG231119280XAG0115",
      "CB72I18SI-2HG231119280XAG0129",
      "CB72I18SI-2HG231119280XAG0248",
      "CB72I18SI-2HG231119280XAG0103",
      "CB72I18SI-2HG231119280XAG0152",
      "CB72I18SI-2HG231119280XAG0106",
      "CB72I18SI-2HG231119280XAG0133",
      "CB72I18SI-2HG231119280XAG0116",
      "CB72I18SI-2HG231119280XAG0136",
      "CB72I18SI-2HG231119280XAG0122",
      "CB72I18SI-2HG231119280XAG0141",
      "CB72I18SI-2HG231119280XAG0110",
      "CB72I18SI-2HG231119280XAG0145",
      "CB72I18SI-2HG231119280XAG0075",
      "CB72I18SI-2HG231119280XAG0265",
      "CB72I18SI-2HG231119280XAG0239",
      "CB72I18SI-2HG231119280XAG0280",
      "CB72I18SI-2HG231119280XAG0092",
      "CB72I18SI-2HG231119280XAG0159",
      "CB72I18SI-2HG231119280XAG0105",
      "CB72I18SI-2HG231119280XAG0164",
      "CB72I18SI-2HG231119280XAG0220",
      "CB72I18SI-2HG231119260XAG0036",
      "CB72I18SI-2HG231119260XAG0138",
      "CB72I18SI-2HG231119260XAG0086",
      "CB72I18SI-2HG231119260XAG0010",
      "CB72I18SI-2HG231119260XAG0007",
      "CB72I18SI-2HG231119260XAG0076",
      "CB72I18SI-2HG231119260XAG0142",
    ],
  );

  let src_path = "E:\\Documents\\WXWork\\1688855640530062\\Cache\\File\\2024-08\\LANmac(1)\\LANmac";
  let save_to = Path::new("E:\\Desktop\\LANmac_new");

  // 使用rayon并行迭代器来并行处理每个条目
  e_utils::fs::tree_folder2(src_path)
    .expect("tree")
    .par_iter() // 将迭代器转换为并行迭代器
    .for_each(|src| {
      if let Some(file_name) = src.file_name().and_then(|os_str| os_str.to_str()) {
        let parts: Vec<&str> = if file_name.contains("IFT") {
          file_name
            .strip_prefix("IFT-START-")
            .unwrap()
            .strip_suffix(".log")
            .unwrap()
            .split("-")
            .take(2)
            .collect()
        } else {
          file_name.split('-').take(2).collect()
        };
        let key = if parts.len() > 1 {
          let merged_string = parts.join("-");
          merged_string
        } else {
          parts[0].to_string()
        };
        for (k, v) in &x {
          if v.par_iter().find_any(|xk| xk == &&&key).is_some() {
            let dst = save_to.join(k).join(file_name);
            dst.auto_create_dir().unwrap();
            copy(src, dst).unwrap();
            break;
          }
        }
      }
    });
}
